

import org.apache.http.message.BasicNameValuePair;

import com.tencent.weibo.api.TAPI;
import com.tencent.weibo.beans.OAuth;
import com.tencent.weibo.utils.QArrayList;

public class TAPIExtend extends TAPI
{
	
	final String tUploadPic = apiBaseUrl+"/t/upload_pic";
	
	
	
	public TAPIExtend(String OAuthVersion)
	{
		super(OAuthVersion);
	}

	
	public String uploadPic(OAuth oAuth, String format, String pic_url, String pic, int pic_type)
			throws Exception 
	{
		String str = null;
		
		QArrayList paramsList = new QArrayList();
		paramsList.add(new BasicNameValuePair("format", format));
		paramsList.add(new BasicNameValuePair("pic_type", String.valueOf(pic_type)));
		
		if(pic != null && !pic.trim().equals(""))
		{
			QArrayList picList = new QArrayList();
			picList.add(new BasicNameValuePair("pic", pic));
			str = requestAPI.postFile(tUploadPic, paramsList, picList, oAuth);
		}
		else
		{
			paramsList.add(new BasicNameValuePair("pic_url", pic_url));
			str = requestAPI.postContent(tUploadPic, paramsList, oAuth);
		}
		
		return str;
		
	}
}
